package com.treasure.mall.biz.dto.wxtemplate;

import com.treasure.mall.biz.dto.BaseSaveDTO;
import com.treasure.mall.zbq.common.ienum.base.CodeDescEnumHelper;
import com.treasure.mall.zbq.common.ienum.wx.TemplateMessageType;
import lombok.Data;

/**
 *
 * <p>
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.biz.dto.wxtemplate
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/8/4 9:57 上午
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 *
 */
@Data
public class SubscribeSaveDTO implements BaseSaveDTO {

    /**
     * 订阅模板消息ID
     */
    private String tempId;

    /**
     * 订阅用户的openid
     */
    private String openId;

    /**
     * 模板消息ID 0 直播开播提醒
     */
    private int messageType = 0;

    /**
     * 获取模板消息类型
     *
     * @return
     */
    public TemplateMessageType getTemplateMessageType() {
        TemplateMessageType templateMessageType = CodeDescEnumHelper.getEnumTypeByCode(TemplateMessageType.class, this.messageType);

        if (templateMessageType != null) {
            return templateMessageType;
        }
        return TemplateMessageType.LIVE;
    }
}
